/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.java.editor;

import com.java.mapbean.Theloai2;
import com.java.service.Theloai2Service;
import java.beans.PropertyEditorSupport;

/**
 *
 * @author quannq
 */
public class TheLoai2Editor extends PropertyEditorSupport {

    public Theloai2Service theLoai2Service;

    public TheLoai2Editor(Theloai2Service theloai2Service) {
        super();
        this.theLoai2Service = theloai2Service;
    }

    @Override
    public void setAsText(String text) throws IllegalArgumentException {
        if (!text.equals("")) {
            Theloai2 emp = theLoai2Service.findId(Integer.parseInt(text));
            setValue(emp);
        } else {
            setValue(null);
        }
    }
}
